<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<%--获取当前时间--%>
<%@ page import="java.sql.*" %>
<jsp:useBean id="now" class="java.util.Date" scope="page"/>
<fmt:formatDate var="nowTime" value="${now}" pattern="yyyy-MM-dd HH:mm:ss"/>
<!DOCTYPE html>
<html>

<%

    String url = "jdbc:mysql://localhost:3306/carxianyu";
    String user = "root";
    String pwd = "root";

    Integer state =Integer.valueOf(request.getParameter("state"));
    String keyword = null;

    String sql = null;
    if(state ==5){
        keyword = request.getParameter("keyword");
        sql =  "select * from carcircle  where name like '%"+keyword+"%' and `status` =22 ";
    }else {
        sql =  "select * from carcircle where `status` =22";
    }


    System.out.println("执行了sql =====》"+sql);

    //jdbc 连接数据库
    Class.forName("com.mysql.jdbc.Driver");//加载驱动
    Connection conn = DriverManager.getConnection("jdbc:mysql://43.142.239.28:13307/carxianyu?useUnicode=true&characterEncoding=UTF-8&serverTimeZone=UTC","root","root");
    PreparedStatement a = conn.prepareStatement(sql);
    ResultSet rs = a.executeQuery();

%>

<head>
    <meta charset="utf-8">
    <title>二手交易平台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctx}/static/layui/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctx}/static/layui/style/template.css" media="all">
    <script src="${ctx}/static/layui/layui.js"></script>
    <script>
        var ctx = '${ctx}/';
    </script>
</head>
<body>
<!--导航条 start-->
<jsp:include page="/head.jsp"/>

<!--导航条 end-->
<jsp:include page="/banner.jsp"/>

<div class="layui-container layadmin-cmdlist-fluid">



    <div class="layui-row layui-col-space30">
        <div class="mainTop layui-clear">
            <div class="fr">
                <form class="layui-form" action="${ctx}/view/front/carCircle/carCircleList.jsp?state=5" method="post">
                    <div class="layui-form-item">
                        <div class="layui-inline" style="text-align: left;">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input dateIcon" name="keyword" id="keyword"
                                       value="${keyword}"
                                       placeholder="请输入车有圈关键词"
                                       style="width: 240px;">
                                <!--复合条件查询-->
                                <input type="hidden" name="state" value="5">
                            </div>

                            <div class="layui-input-inline">
                                <button type="submit" class="layui-btn layui-btn-blue"><i
                                        class="layui-icon layui-icon-search"></i> 搜索
                                </button>
                            </div>
                        </div>
                    </div>

                </form>
            </div>
        </div>
        <c:if test="${sessionScope.username != null}">


        <div class="layui-col-md4 layui-col-sm6">
            <div class="cmdlist-container">
                <!--跳转到 车友圈的评论列表-->
            <a href="${ctx}/view/back/carcircle/carCircleAdd.jsp">
                <img src="http://5b0988e595225.cdn.sohucs.com/images/20180514/9e79fa15efef4892b2205b0bd50f8533.png" style="width: 100%;height: 250px;">
                </a>
                <a href="javascript:;">
                    <div class="cmdlist-text">
                        <p class="info"> 创建个人车友圈</p>
                        <div class="price">
                            <p><span style="color: green">创建个人车友圈</span></p><br>
                        </div>
                    </div>
                </a>
            </div>
        </div>
        </c:if>
        <% while(rs.next()){

            //为列表参数初始化

            Integer id = rs.getInt("id");
            String username = rs.getString("username");
            String introduce = rs.getString("introduce");
            //车圈状态
            Integer statusid =Integer.valueOf(rs.getString("status"));

            String img = rs.getString("img");

            //11 审核中 22正常 33 审核失败
            String status = null;


            if(statusid == 11){
                status = "审核中";
            }else if(statusid == 22){
                status = "正常";
            }else {
                status = "审核拒绝";
            }
            String createtime = rs.getString("createtime");
            String name = rs.getString("name");
            String excuteJsp = "/view/back/carcircle/doCarCirleExcute.jsp?";
            String deleteUri =  excuteJsp+"state=3&id="+id;


        %>

            <div class="layui-col-md4 layui-col-sm6">
                <div class="cmdlist-container">
                    <!--跳转到 车友圈的评论列表-->
                    <a href="${ctx}/view/front/carCircle/carcircleComment.jsp?id=<%=id%>&name=<%=name%>&introduce=<%=introduce%>">
                        <img src="<%=img%>" style="width: 100%;height: 250px;">
                    </a>
                    <a href="javascript:;">
                        <div class="cmdlist-text">
                            <p class="info"><a href="${ctx}/detail?id=<%=id%>"><%=name%></a></p>
                            <div class="price">
                                <p><span style="color: green"><%=introduce%></span></p><br>
                                <p>创建人:<%=username%></p>
                                <span class="flow"><i class="layui-icon layui-icon-date"></i>
                                   <%=createtime%>
                                </span>
                            </div>
                        </div>
                    </a>
                </div>
            </div>


        <%}%>



        <div class="layui-col-md12 layui-col-sm12">
            <div id="demo0"></div>
        </div>
    </div>


</div>


<!--底部区域 start-->

<!--底部区域 end-->
<style>
    .fl {
        float: left;
    }

    .fr {
        float: right;
    }

    .mb10 {
        margin-bottom: 10px;
    }

    .sideBlock {
        padding: 24px;
    }

    .layui-form-item .layui-input-inline {
        width: auto;
    }

    .layui-input, .layui-select, .layui-textarea {
        height: 36px;
    }

    .layui-form-label {
        padding: 8px 15px;
    }

    .layui-form-switch {
        height: 34px;
        line-height: 34px;
        margin-top: 0;
        min-width: 54px;
    }

    .layui-form-switch i {
        width: 24px;
        height: 24px;
        top: 5px;
    }

    .layui-form-onswitch i {
        margin-left: -28px;
        top: 5px;
    }

    .layui-form-switch em {
        margin-left: 27px;
    }

    .layui-form-onswitch em {
        margin-left: 5px;
    }

    .layui-btn {
        height: 36px;
    }

    /*修改颜色风格-蓝色 */
    .layui-form-select dl dd.layui-this {
        background-color: #02a7f0;
    }

    .layui-btn-blue {
        background-color: #02a7f0;
    }

    .layui-form-onswitch {
        border-color: #02a7f0;
        background-color: #02a7f0;
    }

    .layui-form-radio > i:hover, .layui-form-radioed > i {
        color: #02a7f0;
    }

    .layui-form-checked[lay-skin=primary] i {
        border-color: #02a7f0;
        background-color: #02a7f0;
    }

    .layui-form-checkbox[lay-skin=primary]:hover i {
        border-color: #02a7f0;
    }
</style>


<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    var $;
    var layer;
    var element;
    var form;
    layui.use(['element', 'layer', 'jquery', 'form', 'laydate', 'layedit'], function () {
        element = layui.element;
        layer = layui.layer;
        $ = layui.jquery;
        form = layui.form;
        var laydate = layui.laydate;

        //…
    });
</script>

</body>
</html>
